import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';

// 列表属性
export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
  },
  {
    title: '类型',
    dataIndex: 'roleId',
    customRender: ({ record }) => {
      const roleId = record.roleId;
      var text = '';
      var color = '';
      if (roleId === 1) {
        text = '超级管理员';
        color = 'green';
      } else if (roleId === 2) {
        text = '分级管理员';
        color = 'blue';
      } else if (roleId === 3) {
        text = '部门管理员';
        color = 'orange';
      }

      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '管理范围',
    dataIndex: 'deptName',
  }
];


// 表单属性
export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    field: 'userId',
    label: '姓名',
    component: 'Input',
    slot: 'addOperator',
    required: true,
  },
  {
    field: 'userName',
    label: '姓名hidden',
    component: 'Input',
    show: false,
  },
  {
    field: 'roleId',
    label: '类型',
    required: true,
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '超级管理员',
          value: 1,
        },
        {
          label: '分级管理员',
          value: 2,
        },
        {
          label: '部门管理员',
          value: 3,
        },

      ],
    },
  },
  {
    field: 'deptId',
    label: '管理范围',
    component: 'Input',
    slot: 'addOrg',
    required: true,
  },
  {
    field: 'deptName',
    label: '部门名称',
    component: 'Input',
    show: false,
  },
  {
    field: 'deptNameList',
    label: '部门名称列表',
    component: 'Input',
    show: false,
  },

];

